layui.define([ 'form', 'laydate', 'table','appUserApi'], function(exports) {
    var form = layui.form;
    var appUserApi = layui.appUserApi;
    var index = layui.index;
    var view = {
        init:function(){
            Lib.initGenrealForm($("#detailForm"),form);
            // this.initSubmit();
        },
        /*initSubmit:function(){

            $("#updateButton").click(function(){
                form.on('submit(form)', function(){
                    appUserApi.updateAppUser($('#updateForm'),function(){
                        parent.window.dataReload();
                        Common.info("更新成功");
                        Lib.closeFrame();
                    });
                });
            });
            $("#updateButton-cancel").click(function(){
                Lib.closeFrame();
            });

            /!**
             * 更新银行信息
             *!/
            $("#updateBankInfoButton").click(function(){
                form.on('submit(form)', function(){
                    appUserApi.updateBankInfo($('#updateForm'),function(){
                        parent.window.dataReload();
                        Common.info("更新成功");
                        Lib.closeFrame();
                    });
                });
            });

        }*/

    };

   /* /!**
     * 个人账户
     *!/
    $('#bankCityId').on('change', function () {
        getBankBranch();
    });

    /!**
     * 个人账户
     *!/
    showBankBranch = function(){
        if(!$('#bankCityId').val()){
            Common.info("请选择区域");
            return;
        }
        if(!$('#bankId option:selected').val()){
            Common.info("请选择银行");
            return;
        }
    };

    /!**
     * 个人账户
     *!/
    getBankBranch = function(){
        var cityId = $('#bankCityId').val();
        if(!cityId){
            Common.info("请选择区域");
            return;
        }
        var bankId = $('#bankId option:selected').val();
        if(!bankId){
            Common.info("请选择银行");
            return;
        }

        $.ajax({
            type: 'get',
            url: "/cms/bankBranch/branchList.json?cityId=" + cityId + "&bankId=" + bankId,
            async: true,
            success: function (callback) {
                var list = callback.data;
                $('#branchId').empty();
                $('#branchId').append("<option value=''>请选择</option>");
                for (var i = 0; i < list.length; i++) {
                    $('#branchId').append("<option value=" + list[i].id + ">" + list[i].name + "</option>");
                }
                // 设置支行一拉列表
                var tmpBranchId = $('#tmpBranchId').val();
                if(tmpBranchId){
                    $('#branchId').val(tmpBranchId);
                }
                form.render('select');
            },
            error: function (callback) {
                Common.info(callback.responseJSON.msg);
            }
        });
    };

    /!**
     * 公司账户
     *!/
    $('#companyBankCityId').on('change', function () {
        getCompanyBankBranch();
    });
    /!**
     * 公司账户
     *!/
    showCompanyBankBranch = function(){
        if(!$('#companyBankCityId').val()){
            Common.info("请选择区域");
            return;
        }
        if(!$('#companyBankId option:selected').val()){
            Common.info("请选择银行");
            return;
        }
    };

    /!**
     * 公司账户
     *!/
    getCompanyBankBranch = function(){
        var cityId = $('#companyBankCityId').val();
        if(!cityId){
            Common.info("请选择区域");
            return;
        }
        var bankId = $('#companyBankId option:selected').val();
        if(!bankId){
            Common.info("请选择银行");
            return;
        }
        $.ajax({
            type: 'get',
            url: "/cms/bankBranch/branchList.json?cityId=" + cityId + "&bankId=" + bankId,
            async: true,
            success: function (callback) {
                var list = callback.data;
                $('#companyBranchId').empty();
                $('#companyBranchId').append("<option value=''>请选择</option>");
                for (var i = 0; i < list.length; i++) {
                    $('#companyBranchId').append("<option value=" + list[i].id + ">" + list[i].name + "</option>");
                }
                // 设置支行一拉列表
                var tmpCompanyBranchId = $('#tmpCompanyBranchId').val();
                if(tmpCompanyBranchId){
                    $('#companyBranchId').val(tmpCompanyBranchId);
                }
                form.render('select');
            },
            error: function (callback) {
                Common.info(callback.responseJSON.msg);
            }
        });
    };

    /!**
     * 发送验证码
     *!/
    sendCaptcha = function(){
        var tel = $('#tel').val();
        if(!tel){
            Common.info("请输入手机号");
            return;
        }
        Common.post("/cms/smsInfo/sendSms.json",{"tel":tel,"bizType":"2"},function(res){
            console.log('=>',res);
        })
    };*/

    exports('details',view);

});